
  <!DOCTYPE html>
  <html lang="en">

  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <div id="app"></div>
    <br />
    <div id="app1"></div>
    <script src="../js/babel.min.js"></script>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script type="text/babel">
    class Demo extends React.Component {
      state = { data: [] }
    
      add = () => {
        let { data } = this.state
        this.setState({ data: [...data, '黄月月'] })
      }
    
      render() {
        // 和vue一样，当使用数组的index作为索引的时候，删除第一个元素，后面的所有数据节点都将被重新渲染
        return (
          <div>
            <h1>diff DOM</h1>
            <button onClick={this.add}>add</button>
            <ul>
              {
                this.state.data.map((item, index) => {
                  return <li key={index}>{item}</li>
                })
              }
            </ul>
          </div>
        );
      }
    }
    ReactDOM.render(<Demo />, document.getElementById("app"));
    </script>
  </body>

  </html>
